#include "container.hpp"
#include <iostream>

int main() {
    // Create a 10x10 mesh for solving Poisson's equation
    Mesh mesh(10, 10);
    
    // Set boundary conditions on all boundaries
    mesh.setBoundaryCondition(0, 0, 1.0);   // Top-left corner
    mesh.setBoundaryCondition(10, 0, 1.0);  // Top-right corner
    mesh.setBoundaryCondition(0, 10, -1.0); // Bottom-left corner
    mesh.setBoundaryCondition(10, 10, -1.0); // Bottom-right corner
    
    // Set some interior boundary conditions for better convergence
    for (int i = 1; i < 10; ++i) {
        mesh.setBoundaryCondition(i, 0, 0.5);   // Top edge
        mesh.setBoundaryCondition(i, 10, -0.5); // Bottom edge
        mesh.setBoundaryCondition(0, i, 0.5);   // Left edge
        mesh.setBoundaryCondition(10, i, -0.5); // Right edge
    }
    
    // Solve Poisson's equation
    mesh.solvePoisson();
    
    // Print solution at some points
    std::cout << "Solution at (1,1): " << mesh.getValue(1, 1) << std::endl;
    std::cout << "Solution at (5,5): " << mesh.getValue(5, 5) << std::endl;
    std::cout << "Solution at (9,9): " << mesh.getValue(9, 9) << std::endl;
    
    // Demonstrate error handling
    try {
        mesh.getValue(11, 11); // Out of bounds
    } catch (const std::out_of_range& e) {
        std::cout << "Caught expected error: " << e.what() << std::endl;
    }

    return 0;
}